package zgxt;

import java.util.Locale;

public class Test2 {
    public static void main(String[] args) {

    }

    /**
     * 只考虑数字和字母字符
     */
    public boolean isPalindrome (String s) {
        if ("".equals(s)) return true;
        s = s.toLowerCase();
        int left = 0, right = s.length() - 1;
        while (left < right) {
            while (!Character.isLetterOrDigit(s.charAt(left))) left++;
            while (!Character.isLetterOrDigit(s.charAt(right))) right--;
            if (s.charAt(left) != s.charAt(right)) return false;
            left++;
            right--;
        }
        return true;
    }
}
